算例1：
        C101

        VEHICLE
        NUMBER     CAPACITY
        12         200

        CUSTOMER
        CUST NO.  XCOORD.   YCOORD.    DEMAND   READY TIME  DUE DATE   SERVICE   TIME

        0      40         50          0          0       1236          0
        1      45         68         10        912        967         90
        2      45         70         30        825        870         90
        3      42         66         10         65        146         90
        4      42         68         10        727        782         90
        5      42         65         10         15         67         90
        6      40         69         20        621        702         90
        7      40         66         20        170        225         90
        8      38         68         20        255        324         90
        9      38         70         10        534        605         90
        10      35         66         10        357        410         90
        11      35         69         10        448        505         90
        12      25         85         20        652        721         90
        13      22         75         30         30         92         90
        14      22         85         10        567        620         90
        15      20         80         40        384        429         90
        16      20         85         40        475        528         90
        17      18         75         20         99        148         90
        18      15         75         20        179        254         90
        19      15         80         10        278        345         90
        20      30         50         10         10         73         90
        21      30         52         20        914        965         90
        22      28         52         20        812        883         90
        23      28         55         10        732        777         90
        24      25         50         10         65        144         90
        25      25         52         40        169        224         90
        26      25         55         10        622        701         90
        27      23         52         10        261        316         90
        28      23         55         20        546        593         90
        29      20         50         10        358        405         90
        30      20         55         10        449        504         90
        31      10         35         20        200        237         90
        32      10         40         30         31        100         90
        33       8         40         40         87        158         90
        34       8         45         20        751        816         90
        35       5         35         10        283        344         90
        36       5         45         10        665        716         90
        37       2         40         20        383        434         90
        38       0         40         30        479        522         90
        39       0         45         20        567        624         90
        40      35         30         10        264        321         90
        41      35         32         10        166        235         90
        42      33         32         20         68        149         90
        43      33         35         10         16         80         90
        44      32         30         10        359        412         90
        45      30         30         10        541        600         90
        46      30         32         30        448        509         90
        47      30         35         10       1054       1127         90
        48      28         30         10        632        693         90
        49      28         35         10       1001       1066         90
        50      26         32         10        815        880         90
        51      25         30         10        725        786         90
        52      25         35         10        912        969         90
        53      44          5         20        286        347         90
        54      42         10         40        186        257         90
        55      42         15         10         95        158         90
        56      40          5         30        385        436         90
        57      40         15         40         35         87         90
        58      38          5         30        471        534         90
        59      38         15         10        651        740         90
        60      35          5         20        562        629         90
        61      50         30         10        531        610         90
        62      50         35         20        262        317         90
        63      50         40         50        171        218         90
        64      48         30         10        632        693         90
        65      48         40         10         76        129         90
        66      47         35         10        826        875         90
        67      47         40         10         12         77         90
        68      45         30         10        734        777         90
        69      45         35         10        916        969         90
        70      95         30         30        387        456         90
        71      95         35         20        293        360         90
        72      53         30         10        450        505         90
        73      92         30         10        478        551         90
        74      53         35         50        353        412         90
        75      45         65         20        997       1068         90
        76      90         35         10        203        260         90
        77      88         30         10        574        643         90
        78      88         35         20        109        170         90
        79      87         30         10        668        731         90
        80      85         25         10        769        820         90
        81      85         35         30         47        124         90
        82      75         55         20        369        420         90
        83      72         55         10        265        338         90
        84      70         58         20        458        523         90
        85      68         60         30        555        612         90
        86      66         55         10        173        238         90
        87      65         55         20         85        144         90
        88      65         60         30        645        708         90
        89      63         58         10        737        802         90
        90      60         55         10         20         84         90
        91      60         60         10        836        889         90
        92      67         85         20        368        441         90
        93      65         85         40        475        518         90
        94      65         82         10        285        336         90
        95      62         80         30        196        239         90
        96      60         80         10         95        156         90
        97      60         85         30        561        622         90
        98      58         75         20         30         84         90
        99      55         80         10        743        820         90
        100      55         85         20        647        726         90

        result
        routes=
        [[0, 101]
        [0, 5, 3, 7, 8, 10, 11, 9, 6, 4, 2, 1, 75, 101]
        [0, 98, 96, 95, 94, 92, 93, 97, 100, 99, 101]
        [0, 43, 42, 41, 40, 44, 46, 45, 48, 51, 50, 52, 49, 47, 101]
        [0, 81, 78, 76, 71, 70, 73, 77, 79, 80, 101]
        [0, 90, 87, 86, 83, 82, 84, 85, 88, 89, 91, 101]
        [0, 101]
        [0, 32, 33, 31, 35, 37, 38, 39, 36, 34, 101]
        [0, 20, 24, 25, 27, 29, 30, 28, 26, 23, 22, 21, 101]
        [0, 57, 55, 54, 53, 56, 58, 60, 59, 101]
        [0, 67, 65, 63, 62, 74, 72, 61, 64, 68, 66, 69, 101]
        [0, 13, 17, 18, 19, 15, 16, 14, 12, 101]]
        cplex_time 157.077920593s bestcost 827.3


        算例2：
        C102

        VEHICLE
        NUMBER     CAPACITY
        12        200

        CUSTOMER
        CUST NO.  XCOORD.   YCOORD.    DEMAND   READY TIME  DUE DATE   SERVICE   TIME

        0      40         50          0          0       1236          0
        1      45         68         10        912        967         90
        2      45         70         30        825        870         90
        3      42         66         10         65        146         90
        4      42         68         10        727        782         90
        5      42         65         10         15         67         90
        6      40         69         20        621        702         90
        7      40         66         20        170        225         90
        8      38         68         20        255        324         90
        9      38         70         10        534        605         90
        10      35         66         10        357        410         90
        11      35         69         10        448        505         90
        12      25         85         20        652        721         90
        13      22         75         30         30         92         90
        14      22         85         10        567        620         90
        15      20         80         40        384        429         90
        16      20         85         40        475        528         90
        17      18         75         20         99        148         90
        18      15         75         20        179        254         90
        19      15         80         10        278        345         90
        20      30         50         10         10         73         90
        21      30         52         20        914        965         90
        22      28         52         20        812        883         90
        23      28         55         10        732        777         90
        24      25         50         10         65        144         90
        25      25         52         40        169        224         90
        26      25         55         10        622        701         90
        27      23         52         10        261        316         90
        28      23         55         20        546        593         90
        29      20         50         10        358        405         90
        30      20         55         10        449        504         90
        31      10         35         20        200        237         90
        32      10         40         30         31        100         90
        33       8         40         40         87        158         90
        34       8         45         20        751        816         90
        35       5         35         10        283        344         90
        36       5         45         10        665        716         90
        37       2         40         20        383        434         90
        38       0         40         30        479        522         90
        39       0         45         20        567        624         90
        40      35         30         10        264        321         90
        41      35         32         10        166        235         90
        42      33         32         20         68        149         90
        43      33         35         10         16         80         90
        44      32         30         10        359        412         90
        45      30         30         10        541        600         90
        46      30         32         30        448        509         90
        47      30         35         10       1054       1127         90
        48      28         30         10        632        693         90
        49      28         35         10       1001       1066         90
        50      26         32         10        815        880         90
        51      25         30         10        725        786         90
        52      25         35         10        912        969         90
        53      44          5         20        286        347         90
        54      42         10         40        186        257         90
        55      42         15         10         95        158         90
        56      40          5         30        385        436         90
        57      40         15         40         35         87         90
        58      38          5         30        471        534         90
        59      38         15         10        651        740         90
        60      35          5         20        562        629         90
        61      50         30         10        531        610         90
        62      50         35         20        262        317         90
        63      50         40         50        171        218         90
        64      48         30         10        632        693         90
        65      48         40         10         76        129         90
        66      47         35         10        826        875         90
        67      47         40         10         12         77         90
        68      45         30         10        734        777         90
        69      45         35         10        916        969         90
        70      95         30         30        387        456         90
        71      95         35         20        293        360         90
        72      53         30         10        450        505         90
        73      92         30         10        478        551         90
        74      53         35         50        353        412         90
        75      45         65         20        997       1068         90
        76      90         35         10        203        260         90
        77      88         30         10        574        643         90
        78      88         35         20        109        170         90
        79      87         30         10        668        731         90
        80      85         25         10        769        820         90
        81      85         35         30         47        124         90
        82      75         55         20        369        420         90
        83      72         55         10        265        338         90
        84      70         58         20        458        523         90
        85      68         60         30        555        612         90
        86      66         55         10        173        238         90
        87      65         55         20         85        144         90
        88      65         60         30        645        708         90
        89      63         58         10        737        802         90
        90      60         55         10         20         84         90
        91      60         60         10        836        889         90
        92      67         85         20        368        441         90
        93      65         85         40        475        518         90
        94      65         82         10        285        336         90
        95      62         80         30        196        239         90
        96      60         80         10         95        156         90
        97      60         85         30        561        622         90
        98      58         75         20         30         84         90
        99      55         80         10        743        820         90
        100      55         85         20        647        726         90

        result
        routes=
        [[0, 101]
        [0, 5, 3, 7, 8, 10, 11, 9, 6, 4, 2, 1, 75, 101]
        [0, 98, 96, 95, 94, 92, 93, 97, 100, 99, 101]
        [0, 43, 42, 41, 40, 44, 46, 45, 48, 51, 50, 52, 49, 47, 101]
        [0, 81, 78, 76, 71, 70, 73, 77, 79, 80, 101]
        [0, 90, 87, 86, 83, 82, 84, 85, 88, 89, 91, 101]
        [0, 101]
        [0, 32, 33, 31, 35, 37, 38, 39, 36, 34, 101]
        [0, 20, 24, 25, 27, 29, 30, 28, 26, 23, 22, 21, 101]
        [0, 57, 55, 54, 53, 56, 58, 60, 59, 101]
        [0, 67, 65, 63, 62, 74, 72, 61, 64, 68, 66, 69, 101]
        [0, 13, 17, 18, 19, 15, 16, 14, 12, 101]]
        cplex_time 142.142142417s bestcost 827.3


        package vrptw;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Scanner;
import ilog.concert.IloException;
import ilog.concert.IloNumExpr;
import ilog.concert.IloNumVar;
import ilog.concert.IloNumVarType;
import ilog.cplex.IloCplex;
/**
 * @author： huangnan
 * @School: HuaZhong University of science and technology
 * @操作说明：读入不同的文件前要手动修改vetexnum参数，参数值为所有点个数,包括配送中心0和n+1，
 * 代码算例截取于Solomon测试算例
 *
 */
//定义参数
class Data{
   int vetexnum;					//所有点集合n（包括配送中心和客户点，首尾（0和n）为配送中心）
   double E;	      				//配送中心时间窗开始时间
   double	L;	     			 	//配送中心时间窗结束时间
   int vecnum;    					//车辆数
   double cap;     				//车辆载荷
   int[][] vertexs;				//所有点的坐标x,y
   int[] demands;					//需求量
   int[] vehicles;					//车辆编号
   double[] a;						//时间窗开始时间【a[i],b[i]】
   double[] b;						//时间窗结束时间【a[i],b[i]】
   double[] s;						//客户点的服务时间
   int[][] arcs;					//arcs[i][j]表示i到j点的弧
   double[][] dist;				//距离矩阵，满足三角关系,暂用距离表示花费 C[i][j]=dist[i][j]
   //截断小数3.26434-->3.2
   public double double_truncate(double v){
      int iv = (int) v;
      if(iv+1 - v <= 0.000000000001)
         return iv+1;
      double dv = (v - iv) * 10;
      int idv = (int) dv;
      double rv = iv + idv / 10.0;
      return rv;
   }
}
//类功能：解的可行性判断
class Solution{
   double epsilon = 0.0001;
   Data data = new Data();
   ArrayList<ArrayList<Integer>> routes = new ArrayList<>();
   ArrayList<ArrayList<Double>> servetimes = new ArrayList<>();
   public Solution(Data data, ArrayList<ArrayList<Integer>> routes, ArrayList<ArrayList<Double>> servetimes) {
      super();
      this.data = data;
      this.routes = routes;
      this.servetimes = servetimes;
   }
   //函数功能：比较两个数的大小
   public int double_compare(double v1,double v2) {
      if (v1 < v2 - epsilon) {
         return -1;
      }
      if (v1 > v2 + epsilon) {
         return 1;
      }
      return 0;
   }
   //函数功能：解的可行性判断
   public void fesible() throws IloException {
      //车辆数量可行性判断
      if (routes.size() > data.vecnum) {
         System.out.println("error: vecnum!!!");
         System.exit(0);
      }
      //车辆载荷可行性判断
      for (int k = 0; k < routes.size(); k++) {
         ArrayList<Integer> route = routes.get(k);
         double capasity = 0;
         for (int i = 0; i < route.size(); i++) {
            capasity += data.demands[route.get(i)];
         }
         if (capasity > data.cap) {
            System.out.println("error: cap!!!");
            System.exit(0);
         }
      }
      //时间窗、车容量可行性判断
      for (int k = 0; k < routes.size(); k++) {
         ArrayList<Integer> route = routes.get(k);
         ArrayList<Double> servertime = servetimes.get(k);
         double capasity = 0;
         for (int i = 0; i < route.size()-1; i++) {
            int origin = route.get(i);
            int destination = route.get(i+1);
            double si = servertime.get(i);
            double sj = servertime.get(i+1);
            if (si < data.a[origin] && si >  data.b[origin]) {
               System.out.println("error: servertime!");
               System.exit(0);
            }
            if (double_compare(si + data.dist[origin][destination],data.b[destination]) > 0) {
               System.out.println(origin + ": [" + data.a[origin] + ","+data.b[origin]+"]"+ " "+ si);
               System.out.println(destination + ": [" + data.a[destination] + ","+data.b[destination]+"]"+ " "+ sj);
               System.out.println(data.dist[origin][destination]);
               System.out.println(destination + ":" );
               System.out.println("error: forward servertime!");
               System.exit(0);
            }
            if (double_compare(sj - data.dist[origin][destination],data.a[origin]) < 0) {
               System.out.println(origin + ": [" + data.a[origin] + ","+data.b[origin]+"]"+ " "+ si);
               System.out.println(destination + ": [" + data.a[destination] + ","+data.b[destination]+"]"+ " "+ sj);
               System.out.println(data.dist[origin][destination]);
               System.out.println(destination + ":" );
               System.out.println("error: backward servertime!");
               System.exit(0);
            }
         }
         if (capasity > data.cap) {
            System.out.println("error: cap!!!");
            System.exit(0);
         }
      }
   }
}
//类功能：建立模型并求解
public class Vrptw {
   Data data;					//定义类Data的对象
   IloCplex model;				//定义cplex内部类的对象
   public IloNumVar[][][] x;	//x[i][j][k]表示弧arcs[i][j]被车辆k访问
   public IloNumVar[][] w;		//车辆访问所有点的时间矩阵
   double cost;				//目标值object
   Solution solution;
   public Vrptw(Data data) {
      this.data = data;
   }
   //函数功能：解模型，并生成车辆路径和得到目标值
   public void solve() throws IloException {
      ArrayList<ArrayList<Integer>> routes = new ArrayList<>();		//定义车辆路径链表
      ArrayList<ArrayList<Double>> servetimes = new ArrayList<>();	//定义花费时间链表
      //初始化车辆路径和花费时间链表，链表长度为车辆数k
      for (int k = 0; k < data.vecnum; k++) {
         ArrayList<Integer> r = new ArrayList<>();	//定义一个对象为int型的链表
         ArrayList<Double> t = new ArrayList<>();	//定义一个对象为double型的链表
         routes.add(r);								//将上述定义的链表加入到链表routes中
         servetimes.add(t);							//同上
      }
      //判断建立的模型是否可解
      if(model.solve() == false){
         //模型不可解
         System.out.println("problem should not solve false!!!");
         return;										//若不可解，则直接跳出solve函数
      }
      else{
         //模型可解，生成车辆路径
         for(int k = 0; k < data.vecnum; k++){
            boolean terminate = true;
            int i = 0;
            routes.get(k).add(0);
            servetimes.get(k).add(0.0);
            while(terminate){
               for (int j = 0; j < data.vetexnum; j++) {
                  if (data.arcs[i][j]>=0.5 && model.getValue(x[i][j][k])>=0.5) {
                     routes.get(k).add(j);
                     servetimes.get(k).add(model.getValue(w[j][k]));
                     i = j;
                     break;
                  }
               }
               if (i == data.vetexnum-1) {
                  terminate = false;
               }
            }
         }
      }
      solution = new Solution(data,routes,servetimes);
      cost = model.getObjValue();
      System.out.println("routes="+solution.routes);
   }
   //函数功能：根据VRPTW数学模型建立VRPTW的cplex模型
   private void build_model() throws IloException {
      //model
      model = new IloCplex();
      model.setOut(null);
      //variables
      x = new IloNumVar[data.vetexnum][data.vetexnum][data.vecnum];
      w = new IloNumVar[data.vetexnum][data.vecnum];				//车辆访问点的时间
      //定义cplex变量x和w的数据类型及取值范围
      for (int i = 0; i < data.vetexnum; i++) {
         for (int k = 0; k < data.vecnum; k++) {
            w[i][k] = model.numVar(0, 1e15, IloNumVarType.Float, "w" + i + "," + k);
         }
         for (int j = 0; j < data.vetexnum; j++) {
            if (data.arcs[i][j]==0) {
               x[i][j] = null;
            }
            else{
               //Xijk,公式(10)-(11)
               for (int k = 0; k < data.vecnum; k++) {
                  x[i][j][k] = model.numVar(0, 1, IloNumVarType.Int, "x" + i + "," + j + "," + k);
               }
            }
         }
      }
      //加入目标函数
      //公式(1)
      IloNumExpr obj = model.numExpr();
      for(int i = 0; i < data.vetexnum; i++){
         for(int j = 0; j < data.vetexnum; j++){
            if (data.arcs[i][j]==0) {
               continue;
            }
            for(int k = 0; k < data.vecnum; k++){
               obj = model.sum(obj, model.prod(data.dist[i][j], x[i][j][k]));
            }
         }
      }
      model.addMinimize(obj);
      //加入约束
      //公式(2)
      for(int i= 1; i < data.vetexnum-1;i++){
         IloNumExpr expr1 = model.numExpr();
         for (int k = 0; k < data.vecnum; k++) {
            for (int j = 1; j < data.vetexnum; j++) {
               if (data.arcs[i][j]==1) {
                  expr1 = model.sum(expr1, x[i][j][k]);
               }
            }
         }
         model.addEq(expr1, 1);
      }
      //公式(3)
      for (int k = 0; k < data.vecnum; k++) {
         IloNumExpr expr2 = model.numExpr();
         for (int j = 1; j < data.vetexnum; j++) {
            if (data.arcs[0][j]==1) {
               expr2 = model.sum(expr2, x[0][j][k]);
            }
         }
         model.addEq(expr2, 1);
      }
      //公式(4)
      for (int k = 0; k < data.vecnum; k++) {
         for (int j = 1; j < data.vetexnum-1; j++) {
            IloNumExpr expr3 = model.numExpr();
            IloNumExpr subExpr1 = model.numExpr();
            IloNumExpr subExpr2 = model.numExpr();
            for (int i = 0; i < data.vetexnum; i++) {
               if (data.arcs[i][j]==1) {
                  subExpr1 = model.sum(subExpr1,x[i][j][k]);
               }
               if (data.arcs[j][i]==1) {
                  subExpr2 = model.sum(subExpr2,x[j][i][k]);
               }
            }
            expr3 = model.sum(subExpr1,model.prod(-1, subExpr2));
            model.addEq(expr3, 0);
         }
      }
      //公式(5)
      for (int k = 0; k < data.vecnum; k++) {
         IloNumExpr expr4 = model.numExpr();
         for (int i = 0; i < data.vetexnum-1; i++) {
            if (data.arcs[i][data.vetexnum-1]==1) {
               expr4 = model.sum(expr4,x[i][data.vetexnum-1][k]);
            }
         }
         model.addEq(expr4, 1);
      }
      //公式(6)
      double M = 1e5;
      for (int k = 0; k < data.vecnum; k++) {
         for (int i = 0; i < data.vetexnum; i++) {
            for (int j = 0; j < data.vetexnum; j++) {
               if (data.arcs[i][j] == 1) {
                  IloNumExpr expr5 = model.numExpr();
                  IloNumExpr expr6 = model.numExpr();
                  expr5 = model.sum(w[i][k], data.s[i]+data.dist[i][j]);
                  expr5 = model.sum(expr5,model.prod(-1, w[j][k]));
                  expr6 = model.prod(M,model.sum(1,model.prod(-1, x[i][j][k])));
                  model.addLe(expr5, expr6);
               }
            }
         }
      }
      //公式(7)
      for (int k = 0; k < data.vecnum; k++) {
         for (int i = 1; i < data.vetexnum-1; i++) {
            IloNumExpr expr7 = model.numExpr();
            for (int j = 0; j < data.vetexnum; j++) {
               if (data.arcs[i][j] == 1) {
                  expr7 = model.sum(expr7,x[i][j][k]);
               }
            }
            model.addLe(model.prod(data.a[i], expr7), w[i][k]);
            model.addLe(w[i][k], model.prod(data.b[i], expr7));
         }
      }
      //公式(8)
      for (int k = 0; k < data.vecnum; k++) {
         model.addLe(data.E, w[0][k]);
         model.addLe(data.E, w[data.vetexnum-1][k]);
         model.addLe(w[0][k], data.L);
         model.addLe(w[data.vetexnum-1][k], data.L);
      }
      //公式(9)
      for (int k = 0; k < data.vecnum; k++) {
         IloNumExpr expr8 = model.numExpr();
         for (int i = 1; i < data.vetexnum-1; i++) {
            IloNumExpr expr9 = model.numExpr();
            for (int j = 0; j < data.vetexnum; j++) {
               if (data.arcs[i][j] == 1) {
                  expr9=model.sum(expr9,x[i][j][k]);
               }
            }
            expr8 = model.sum(expr8,model.prod(data.demands[i],expr9));
         }
         model.addLe(expr8, data.cap);
      }
   }
   //函数功能：从txt文件中读取数据并初始化参数
   public static void process_solomon(String path,Data data,int vetexnum) throws Exception{
      String line = null;
      String[] substr = null;
      Scanner cin = new Scanner(new BufferedReader(new FileReader(path)));  //读取文件
      for(int i =0; i < 4;i++){
         line = cin.nextLine();  //读取一行
      }
      line = cin.nextLine();
      line.trim(); //返回调用字符串对象的一个副本，删除起始和结尾的空格
      substr = line.split(("\\s+")); //以空格为标志将字符串拆分
      //初始化参数
      data.vetexnum = vetexnum;
      data.vecnum = Integer.parseInt(substr[1]);
      data.cap = Integer.parseInt(substr[2]);
      data.vertexs =new int[data.vetexnum][2];				//所有点的坐标x,y
      data.demands = new int[data.vetexnum];					//需求量
      data.vehicles = new int[data.vecnum];					//车辆编号
      data.a = new double[data.vetexnum];						//时间窗开始时间
      data.b = new double[data.vetexnum];						//时间窗结束时间
      data.s = new double[data.vetexnum];						//服务时间
      data.arcs = new int[data.vetexnum][data.vetexnum];
      data.dist = new double[data.vetexnum][data.vetexnum];	//距离矩阵，满足三角关系,用距离表示cost
      for(int i =0; i < 4;i++){
         line = cin.nextLine();
      }
      //读取vetexnum-1行数据
      for (int i = 0; i < data.vetexnum - 1; i++) {
         line = cin.nextLine();
         line.trim();
         substr = line.split("\\s+");
         data.vertexs[i][0] = Integer.parseInt(substr[2]);
         data.vertexs[i][1] = Integer.parseInt(substr[3]);
         data.demands[i] = Integer.parseInt(substr[4]);
         data.a[i] = Integer.parseInt(substr[5]);
         data.b[i] = Integer.parseInt(substr[6]);
         data.s[i] = Integer.parseInt(substr[7]);
      }
      cin.close();//关闭流
      //初始化配送中心参数
      data.vertexs[data.vetexnum-1] = data.vertexs[0];
      data.demands[data.vetexnum-1] = 0;
      data.a[data.vetexnum-1] = data.a[0];
      data.b[data.vetexnum-1] = data.b[0];
      data.E = data.a[0];
      data.L = data.b[0];
      data.s[data.vetexnum-1] = 0;
      double min1 = 1e15;
      double min2 = 1e15;
      //距离矩阵初始化
      for (int i = 0; i < data.vetexnum; i++) {
         for (int j = 0; j < data.vetexnum; j++) {
            if (i == j) {
               data.dist[i][j] = 0;
               continue;
            }
            data.dist[i][j] = Math.sqrt((data.vertexs[i][0]-data.vertexs[j][0])*(data.vertexs[i][0]-data.vertexs[j][0])+
                    (data.vertexs[i][1]-data.vertexs[j][1])*(data.vertexs[i][1]-data.vertexs[j][1]));
            data.dist[i][j]=data.double_truncate(data.dist[i][j]);
         }
      }
      data.dist[0][data.vetexnum-1] = 0;
      data.dist[data.vetexnum-1][0] = 0;
      //距离矩阵满足三角关系
      for (int  k = 0; k < data.vetexnum; k++) {
         for (int i = 0; i < data.vetexnum; i++) {
            for (int j = 0; j < data.vetexnum; j++) {
               if (data.dist[i][j] > data.dist[i][k] + data.dist[k][j]) {
                  data.dist[i][j] = data.dist[i][k] + data.dist[k][j];
               }
            }
         }
      }
      //初始化为完全图
      for (int i = 0; i < data.vetexnum; i++) {
         for (int j = 0; j < data.vetexnum; j++) {
            if (i != j) {
               data.arcs[i][j] = 1;
            }
            else {
               data.arcs[i][j] = 0;
            }
         }
      }
      //除去不符合时间窗和容量约束的边
      for (int i = 0; i < data.vetexnum; i++) {
         for (int j = 0; j < data.vetexnum; j++) {
            if (i == j) {
               continue;
            }
            if (data.a[i]+data.s[i]+data.dist[i][j]>data.b[j] || data.demands[i]+data.demands[j]>data.cap) {
               data.arcs[i][j] = 0;
            }
            if (data.a[0]+data.s[i]+data.dist[0][i]+data.dist[i][data.vetexnum-1]>data.b[data.vetexnum-1]) {
               System.out.println("the calculating example is false");

            }
         }
      }
      for (int i = 1; i < data.vetexnum-1; i++) {
         if (data.b[i] - data.dist[0][i] < min1) {
            min1 = data.b[i] - data.dist[0][i];
         }
         if (data.a[i] + data.s[i] + data.dist[i][data.vetexnum-1] < min2) {
            min2 = data.a[i] + data.s[i] + data.dist[i][data.vetexnum-1];
         }
      }
      if (data.E > min1 || data.L < min2) {
         System.out.println("Duration false!");
         System.exit(0);//终止程序
      }
      //初始化配送中心0，n+1两点的参数
      data.arcs[data.vetexnum-1][0] = 0;
      data.arcs[0][data.vetexnum-1] = 1;
      for (int i = 1; i < data.vetexnum-1; i++) {
         data.arcs[data.vetexnum-1][i] = 0;
      }
      for (int i = 1; i < data.vetexnum-1; i++) {
         data.arcs[i][0] = 0;
      }
   }
   public static void main(String[] args) throws Exception {
      Data data = new Data();
      int vetexnum = 102;//所有点个数，包括0，n+1两个配送中心点
      //读入不同的文件前要手动修改vetexnum参数，参数值等于所有点个数,包括配送中心
      String path = "data/c101.txt";//算例地址
      process_solomon(path,data,vetexnum);
      System.out.println("input succesfully");
      System.out.println("cplex procedure###########################");
      Vrptw cplex = new Vrptw(data);
      cplex.build_model();
      double cplex_time1 = System.nanoTime();
      cplex.solve();
      cplex.solution.fesible();
      double cplex_time2 = System.nanoTime();
      double cplex_time = (cplex_time2 - cplex_time1) / 1e9;//求解时间，单位s
      System.out.println("cplex_time " + cplex_time + " bestcost " + cplex.cost);
   }
}

